<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
    <head>
        <title>SecureMail Messages</title>
        <meta charset="utf-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <link rel="icon" type="image/x-icon" href="/assets/img/favicon.ico" th:href="@{/assets/img/favicon.ico}"/>
        <link rel="stylesheet" href="/webjars/bootstrap/css/bootstrap.css" th:href="@{/webjars/bootstrap/css/bootstrap.css}" />
        <link rel="stylesheet" href="/assets/css/custom.css" th:href="@{/assets/css/custom.css}"/>
    </head>
    <body>
        <div th:substituteby="admin/templates::header"></div>
        <div class="container">
            <h1>Messages</h1>
            <br />
            <div>
                <table class="table table-striped">
                    <thead>
                        <tr>
                            <th class="col-sm-2">Created</th>
                            <th class="col-sm-2">To</th>
                            <th class="col-sm-2">From</th>
                            <th class="col-sm-5">Summary</th>
                            <th class="col-sm-1">Delete</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr th:each="message : ${messages}">
                            <td class="col-sm-2" th:text="${#calendars.format(message.created, 'dd/MMM/yyyy hh:mm a')}">Created</td>
                            <td class="col-sm-2" th:text="${message.to.firstName + ' ' + message.to.lastName}">To</td>
                            <td class="col-sm-2" th:text="${message.from.firstName + ' ' + message.from.lastName}">From</td>
                            <td class="col-sm-5" th:text="${message.summary}">Summary</td>
                            <td class="col-sm-1">
                                <div>
                                    <form action="#" th:action="@{/admin/messages/{messageId}(messageId=${message.id})}" th:method="delete">
                                        <input type="submit" value="Delete" class="btn btn-default btn-sm" />
                                    </form>
                                </div>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <div th:substituteby="admin/templates::footer"></div>
        <script src="/webjars/jquery/jquery.min.js" th:src="@{/webjars/jquery/jquery.min.js}"></script>
        <script src="/webjars/bootstrap/js/bootstrap.min.js" th:src="@{/webjars/bootstrap/js/bootstrap.min.js}"></script>
    </body>
</html>
